package edu.hawaii.wattwaiter.page;

import org.apache.wicket.extensions.markup.html.tabs.AbstractTab;
import org.apache.wicket.extensions.markup.html.tabs.TabbedPanel;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.Model;

/**
 * Tabs Panel.
 * @author Remy
 *
 */
public class MyTabs extends AbstractTab {
  
  private static final long serialVersionUID = 1L;

  private Panel p;

  /**
   * Constructor for Tabs.
   * @param label - takes label
   */
  public MyTabs(String label) {
    super(new Model<String>(label));
  }
  
  @Override
  public Panel getPanel(String panelId) {
   if (p == null) {
    // Lazily create the panel
     p = createPanel();
     if (!TabbedPanel.TAB_PANEL_ID.equals(p.getId())) {
       throw new IllegalArgumentException (
         "Panel id must be TabbedPanel.TAB_PANEL_ID");
     }
     p.setOutputMarkupId(true);
   }
   return p;
  }
  
  /**
   * Exception Handling.
   * @return exception - has to be panel
   */
  protected Panel createPanel() {
   throw new IllegalArgumentException("Must provide a panel");
  }
 }

